package com.firesafe.repair.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.firesafe.repair.entity.RepairRecordEntity;
import com.firesafe.repair.service.RepairRecordService;
import com.firesafe.common.utils.PageUtils;
import com.firesafe.common.utils.R;



/**
 * 消防设备的维修记录表
 *
 * @author Liu
 * @email 
 * @date 2024-03-26 16:39:40
 */
@RestController
@RequestMapping("repair/repairrecord")
public class RepairRecordController {
    @Autowired
    private RepairRecordService repairRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = repairRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		RepairRecordEntity repairRecord = repairRecordService.getById(id);

        return R.ok().put("repairRecord", repairRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody RepairRecordEntity repairRecord){
		repairRecordService.save(repairRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody RepairRecordEntity repairRecord){
		repairRecordService.updateById(repairRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		repairRecordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
